ARCH ?= x86

ifneq ($(ARCH),x86)
ifneq ($(SDKTARGETSYSROOT),)
CC := $(CXX)
else
CC = /opt/gbaide/toolchain/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-
endif
else
CC = g++
endif

current_path := $(shell pwd)
#源文件目录SRC_DIR
SRC_DIRS := $(current_path)/src
SRC_C_EXTRA :=
HEADERS := 
INCLUDE_DIRS := $(current_path)/include/inner
EXTRACTED_DIRS := $(sort $(dir $(HEADERS)))
INCLUDE_DIRS += $(EXTRACTED_DIRS)

LIBRARY_DIRS := $(current_path)/lib
LIBRARIES := 

BUILD_DIR = $(current_path)/bin

CFLAGS := 
CFLAGS += $(addprefix -I,$(INCLUDE_DIRS))
CFLAGS += $(addprefix -L,$(LIBRARY_DIRS))
CFLAGS += $(LIBRARIES)

SRC := $(wildcard $(foreach dir,$(SRC_DIRS),$(dir)/*.cpp))
SRC += $(SRC_C_EXTRA)

OBJ := $(patsubst %.cpp,%.o,$(SRC))

TARGET := $(BUILD_DIR)/main
all: $(TARGET)

$(TARGET): $(OBJ)
	$(CC) -o $@ $^ $(CFLAGS)

%.o: %.cpp
	$(CC) $(CFLAGS) -c $< -o $@

clean:
	rm -rf $(TARGET)
	find . -type f -name "*.o" -exec rm -f {} +
.PHONY: all clean
